package com.imy.rootserver.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class SPUtils {
    private static boolean init = false;
    private static SharedPreferences sharedPreferences;

    public static void setString(Context context, String key, String value) {
        checkInit(context);
        sharedPreferences.edit().putString(key, value);
        sharedPreferences.edit().commit();
    }

    public static String getString(Context context, String key, String defaultValue) {
        checkInit(context);
        return sharedPreferences.getString(key, defaultValue);
    }

    private static void checkInit(Context context) {
        if (init) {
            return;
        }
        sharedPreferences = context.getSharedPreferences("data", Context.MODE_PRIVATE);
        init = true;
    }
}
